package com.runda;

import javax.servlet.MultipartConfigElement;


import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class AppWebMvcConfigurer extends WebMvcConfigurerAdapter {
	
	@Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**");
    }
	
	
	//设置上传文件大小
	// @Bean  
	// EmbeddedServletContainerCustomizer containerCustomizer() throws Exception {  
	//     return (ConfigurableEmbeddedServletContainer container) -> {  
	//         if (container instanceof TomcatEmbeddedServletContainerFactory) {  
	//             TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container;  
	//             tomcat.addConnectorCustomizers((connector) -> {  
	//                 connector.setMaxPostSize(10000000); // 10 MB  
	//                 connector.setMaxPostSize(1000000000); // 100 MB  
	//             });  
	//         }  
	//     };
	// }
	
	 @Bean
	 MultipartConfigElement multipartConfigElement() {
		MultipartConfigFactory factory = new MultipartConfigFactory();
		factory.setLocation("/mnt/resource/tmp");
	    return factory.createMultipartConfig();
	}
}
